/**
 * 文章相关请求模块
 */
import request from '@/utils/request'

/**
  * 获取文章列表
  */
export const getArticles = params => {
  return request({
    method: 'GET',
    url: '/v1_0/articles',
    params
  })
}

/**
 * 根据 id 获取指定文章
 */
export const getArticleById = articleId => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${articleId}`
  })
}

/**
 * 对文章点赞
 */
export const artLikings = articleId => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target: articleId
    }
  })
}

/**
 * 取消对文章点赞
 */
export const artUnLikings = articleId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${articleId}`
  })
}

/**
 * 收藏文章
 */
export const artCollect = articleId => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target: articleId
    }
  })
}

/**
 * 取消对文章收藏
 */
export const artUnCollect = articleId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${articleId}`
  })
}

/**
 * 对文章不喜欢
 */
export const artDislikes = articleId => {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}

/**
 * 取消对文章不喜欢
 */
export const artUnDislikes = articleId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/dislikes/${articleId}`
  })
}

/**
 * 举报文章
 */
export const artReports = data => {
  return request({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: data
  })
}

/**
 * 获取文章新闻推荐
 */
export const getArticlesRecommed = channelId => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${channelId}`
  })
}

/**
 * 获取新闻详情
 */
export const getarticleDetail = articleId => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${articleId}`
  })
}

/**
 * 获取用户收藏列表
 */
export const artcollections = params => {
  return request({
    method: 'GET',
    url: '/v1_0/article/collections',
    params
  })
}

/**
 * 获取用户阅读历史
 */
export const arthistories = params => {
  return request({
    method: 'GET',
    url: '/v1_0/user/histories',
    params
  })
}
